package baseFx.database.query;

import baseFx.database.MultipleReader;
import baseFx.database.SqlParam;

import java.util.List;

public abstract class AbstractQuery extends AbstractEntityQuery implements DbQuery {
    private SqlQuery query;

    public AbstractQuery(SqlQuery query) {
        super(query);
        this.query = query;
    }

    @Override
    public <T> List<T> query(Class<T> clazz, SqlParam param) {
        return query.query(clazz, param);
    }

    @Override
    public MultipleReader multiple(SqlParam param) {
        return query.multiple(param);
    }

    @Override
    public <T> PageData<T> pager(Class<T> clazz, PageSet pageSet, SqlParam param) {
        return query.pager(clazz, pageSet, param);
    }

    @Override
    public boolean isClosed() {
        return query == null || query.isClosed();
    }

    @Override
    public void close() {
        super.close();
        query = null;
    }
}
